<?php
/**
 * @Copyright   2008, XXXX-XXXX
 * All rights reserved. 
 * feature summary.
 * @filesource  ReleaseSlaveCommand.php 
 * @author      lipeng <lipengage@gmain.com> 
 * @package     / 
 * @version     $Id: $ 
 */

class ReleaseSlaveCommand extends DostuffCommand{
	public function excute() {

		if ($this->get_player()) {
			return true;
		}
		if ($this->is_slave() === true || $this->is_slave() === -1) {
			return true;
		}

		if ($this->check_cmd_catalog("messageId")) {
			return true;
		}

		//save activity
		$new_activity = $this->new_activity(activity_dao::$BUY);
		$this->activitydb->activity_insert($new_activity);

		//save user;
		$this->target["master_id"] = '';
		$this->target["master_name"] = '';
		$this->target["nickname"] = '';
		$this->actor["capital"] -= $this->target["price"];
		$this->actor["slave_num"] -= 1;
		$this->userdb->user_update_byid($this->container, $this->target["uid"], $this->target);
		$this->userdb->user_update_byid($this->container, $this->actor["uid"], $this->actor);

		$this->set_haserror(false);
		$this->set_messageid(command::$RELEASE);
		return false;
	}
}
?>